package com.wyl.aop.cglib.aop;

import com.wyl.aop.cglib.service.CglibAopService;
import com.wyl.aop.cglib.service.impl.CglibAopServiceImpl;
import net.sf.cglib.proxy.Enhancer;

public class CglibAopServiceProxyFactory {

    public static CglibAopServiceImpl createProxy() {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(CglibAopServiceImpl.class);
        enhancer.setCallback(new CglibAspect());
        // 调用无参构造方法
        return (CglibAopServiceImpl) enhancer.create();
    }
}